/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hanscan.persistence;

import javax.persistence.EntityManager;
import javax.persistence.Persistence;

/**
 *
 * @author laura
 */
public class EntityManagerSingleton
{

    private static EntityManager instance = null;

    // Private constructor suppresses
    private EntityManagerSingleton()
    {
    }

    // creador sincronizado para protegerse de posibles problemas  multi-hilo
    // otra prueba para evitar instantiación múltiple
    private synchronized static void createInstance()
    {
        if (instance == null)
        {
            instance = Persistence.createEntityManagerFactory("MABASFPC").createEntityManager();
        }
    }

    public static EntityManager getInstance()
    {
        if (instance == null)
        {
            createInstance();
        }
        return instance;
    }
}